//
//  ViewController.m
//  手势解锁
//
//  Created by mac on 15/10/28.
//  Copyright (c) 2015年 Wu. All rights reserved.
//

#import "ViewController.h"
#import "SambooView.h"
#import "SVProgressHUD.h"
#import "MainViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet SambooView* pwdView;
@property (weak, nonatomic) IBOutlet UIImageView* imageView;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    // 设置背景图片
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Home_refresh_bg"]];
    
    self.pwdView.pwdBlock = ^(NSString* pwd, UIImage* img) {
        NSLog(@"%@-----", pwd);
        
        self.imageView.image = img;
        
        if ([pwd isEqualToString:@"012"]) {
            
            self.imageView.image = nil;
            
            // 正确
            [SVProgressHUD showSuccessWithStatus:@"密码正确"];
            
            // 创建需要跳转的vc
            MainViewController* vc = [[MainViewController alloc] init];
            
            [self presentViewController:vc animated:YES completion:nil];
            return YES;
        }
        else {
            // 错误
            [SVProgressHUD showErrorWithStatus:@"密码错误"];
            return NO;
        }
    };
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
